<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Constructs a new, empty cluster layout. Layouts are not typically
<span class='line'>  3</span>  * constructed directly; instead, they are added to an existing panel via
<span class='line'>  4</span>  * {@link pv.Mark#add}.
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * @class Implements a hierarchical layout using the cluster (or dendrogram)
<span class='line'>  7</span>  * algorithm. This layout provides both node-link and space-filling
<span class='line'>  8</span>  * implementations of cluster diagrams. In many ways it is similar to
<span class='line'>  9</span>  * {@link pv.Layout.Partition}, except that leaf nodes are positioned at maximum
<span class='line'> 10</span>  * depth, and the depth of internal nodes is based on their distance from their
<span class='line'> 11</span>  * deepest descendant, rather than their distance from the root.
<span class='line'> 12</span>  *
<span class='line'> 13</span>  * &lt;p>The cluster layout supports a "group" property, which if true causes
<span class='line'> 14</span>  * siblings to be positioned closer together than unrelated nodes at the same
<span class='line'> 15</span>  * depth. Unlike the partition layout, this layout does not support dynamic
<span class='line'> 16</span>  * sizing for leaf nodes; all leaf nodes are the same size.
<span class='line'> 17</span>  *
<span class='line'> 18</span>  * &lt;p>For more details on how to use this layout, see
<span class='line'> 19</span>  * {@link pv.Layout.Hierarchy}.
<span class='line'> 20</span>  *
<span class='line'> 21</span>  * @see pv.Layout.Cluster.Fill
<span class='line'> 22</span>  * @extends pv.Layout.Hierarchy
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> </span><span class="NAME">pv.Layout.Cluster</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Hierarchy.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">interpolate</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// cached interpolate</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">      </span><span class="NAME">buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.buildImplied</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="WHIT">  </span><span class="COMM">/** @private Cache layout state to optimize properties. */</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="WHIT">  </span><span class="NAME">this.buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">    </span><span class="NAME">buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">    </span><span class="NAME">interpolate</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">        </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/^(top|bottom)$/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">s.orient</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"step-before"</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">        </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="REGX">/^(left|right)$/</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">s.orient</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"step-after"</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">        </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"linear"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> 
<span class='line'> 38</span> </span><span class="WHIT">  </span><span class="NAME">this.link.interpolate</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">interpolate</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> 
<span class='line'> 41</span> </span><span class="NAME">pv.Layout.Cluster.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"group"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"orient"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"innerRadius"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">property</span><span class="PUNC">(</span><span class="STRN">"outerRadius"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span> 
<span class='line'> 47</span> </span><span class="COMM">/**
<span class='line'> 48</span>  * The group parameter; defaults to 0, disabling grouping of siblings. If this
<span class='line'> 49</span>  * parameter is set to a positive number (or true, which is equivalent to 1),
<span class='line'> 50</span>  * then additional space will be allotted between sibling groups. In other
<span class='line'> 51</span>  * words, siblings (nodes that share the same parent) will be positioned more
<span class='line'> 52</span>  * closely than nodes at the same depth that do not share a parent.
<span class='line'> 53</span>  *
<span class='line'> 54</span>  * @type number
<span class='line'> 55</span>  * @name pv.Layout.Cluster.prototype.group
<span class='line'> 56</span>  */</span><span class="WHIT">
<span class='line'> 57</span> 
<span class='line'> 58</span> </span><span class="COMM">/**
<span class='line'> 59</span>  * The orientation. The default orientation is "top", which means that the root
<span class='line'> 60</span>  * node is placed on the top edge, leaf nodes appear on the bottom edge, and
<span class='line'> 61</span>  * internal nodes are in-between. The following orientations are supported:&lt;ul>
<span class='line'> 62</span>  *
<span class='line'> 63</span>  * &lt;li>left - left-to-right.
<span class='line'> 64</span>  * &lt;li>right - right-to-left.
<span class='line'> 65</span>  * &lt;li>top - top-to-bottom.
<span class='line'> 66</span>  * &lt;li>bottom - bottom-to-top.
<span class='line'> 67</span>  * &lt;li>radial - radially, with the root at the center.&lt;/ul>
<span class='line'> 68</span>  *
<span class='line'> 69</span>  * @type string
<span class='line'> 70</span>  * @name pv.Layout.Cluster.prototype.orient
<span class='line'> 71</span>  */</span><span class="WHIT">
<span class='line'> 72</span> 
<span class='line'> 73</span> </span><span class="COMM">/**
<span class='line'> 74</span>  * The inner radius; defaults to 0. This property applies only to radial
<span class='line'> 75</span>  * orientations, and can be used to compress the layout radially. Note that for
<span class='line'> 76</span>  * the node-link implementation, the root node is always at the center,
<span class='line'> 77</span>  * regardless of the value of this property; this property only affects internal
<span class='line'> 78</span>  * and leaf nodes. For the space-filling implementation, a non-zero value of
<span class='line'> 79</span>  * this property will result in the root node represented as a ring rather than
<span class='line'> 80</span>  * a circle.
<span class='line'> 81</span>  *
<span class='line'> 82</span>  * @type number
<span class='line'> 83</span>  * @name pv.Layout.Cluster.prototype.innerRadius
<span class='line'> 84</span>  */</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="COMM">/**
<span class='line'> 87</span>  * The outer radius; defaults to fill the containing panel, based on the height
<span class='line'> 88</span>  * and width of the layout. If the layout has no height and width specified, it
<span class='line'> 89</span>  * will extend to fill the enclosing panel.
<span class='line'> 90</span>  *
<span class='line'> 91</span>  * @type number
<span class='line'> 92</span>  * @name pv.Layout.Cluster.prototype.outerRadius
<span class='line'> 93</span>  */</span><span class="WHIT">
<span class='line'> 94</span> 
<span class='line'> 95</span> </span><span class="COMM">/**
<span class='line'> 96</span>  * Defaults for cluster layouts. The default group parameter is 0 and the
<span class='line'> 97</span>  * default orientation is "top".
<span class='line'> 98</span>  *
<span class='line'> 99</span>  * @type pv.Layout.Cluster
<span class='line'>100</span>  */</span><span class="WHIT">
<span class='line'>101</span> </span><span class="NAME">pv.Layout.Cluster.prototype.defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">pv.Layout.Cluster</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">extend</span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy.prototype.defaults</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">group</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">    </span><span class="PUNC">.</span><span class="NAME">orient</span><span class="PUNC">(</span><span class="STRN">"top"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> 
<span class='line'>106</span> </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>107</span> </span><span class="NAME">pv.Layout.Cluster.prototype.buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.Layout.Hierarchy.prototype.buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>109</span> 
<span class='line'>110</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">root</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.nodes</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">      </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">s.group</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">      </span><span class="NAME">breadth</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">      </span><span class="NAME">depth</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">      </span><span class="NAME">leafCount</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">      </span><span class="NAME">leafIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NUMB">5</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> 
<span class='line'>117</span> </span><span class="WHIT">  </span><span class="COMM">/* Count the leaf nodes and compute the depth of descendants. */</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">  </span><span class="NAME">root.visitAfter</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.firstChild</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">        </span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pv.max</span><span class="PUNC">(</span><span class="NAME">n.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.depth</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">          </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">          </span><span class="NAME">leafCount</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">        </span><span class="NAME">leafCount</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">        </span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">  </span><span class="NAME">breadth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">leafCount</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">  </span><span class="NAME">depth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NAME">root.depth</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> 
<span class='line'>134</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute the unit breadth and depth of each node. */</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">  </span><span class="NAME">root.visitAfter</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.firstChild</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">        </span><span class="NAME">n.breadth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.mean</span><span class="PUNC">(</span><span class="NAME">n.childNodes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.breadth</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">group</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">          </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">          </span><span class="NAME">leafIndex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">group</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">        </span><span class="NAME">n.breadth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">breadth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">leafIndex</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">      </span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">depth</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> 
<span class='line'>149</span> </span><span class="WHIT">  </span><span class="COMM">/* Compute breadth and depth ranges for space-filling layouts. */</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">  </span><span class="NAME">root.visitAfter</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">      </span><span class="NAME">n.minBreadth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.firstChild</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">n.firstChild.minBreadth</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.breadth</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">breadth</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">      </span><span class="NAME">n.maxBreadth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.firstChild</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">n.lastChild.maxBreadth</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.breadth</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">breadth</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">  </span><span class="NAME">root.visitBefore</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">      </span><span class="NAME">n.minDepth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">n.parentNode.maxDepth</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">      </span><span class="NAME">n.maxDepth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.parentNode</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">          </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.depth</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">root.depth</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">          </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.minDepth</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NAME">root.depth</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">  </span><span class="NAME">root.minDepth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">depth</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> 
<span class='line'>168</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Hierarchy.NodeLink.buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</span> </span><span class="COMM">/**
<span class='line'>172</span>  * Constructs a new, empty space-filling cluster layout. Layouts are not
<span class='line'>173</span>  * typically constructed directly; instead, they are added to an existing panel
<span class='line'>174</span>  * via {@link pv.Mark#add}.
<span class='line'>175</span>  *
<span class='line'>176</span>  * @class A variant of cluster layout that is space-filling. The meaning of the
<span class='line'>177</span>  * exported mark prototypes changes slightly in the space-filling
<span class='line'>178</span>  * implementation:&lt;ul>
<span class='line'>179</span>  *
<span class='line'>180</span>  * &lt;li>&lt;tt>node&lt;/tt> - for rendering nodes; typically a {@link pv.Bar} for
<span class='line'>181</span>  * non-radial orientations, and a {@link pv.Wedge} for radial orientations.
<span class='line'>182</span>  *
<span class='line'>183</span>  * &lt;p>&lt;li>&lt;tt>link&lt;/tt> - unsupported; undefined. Links are encoded implicitly
<span class='line'>184</span>  * in the arrangement of the space-filling nodes.
<span class='line'>185</span>  *
<span class='line'>186</span>  * &lt;p>&lt;li>&lt;tt>label&lt;/tt> - for rendering node labels; typically a
<span class='line'>187</span>  * {@link pv.Label}.
<span class='line'>188</span>  *
<span class='line'>189</span>  * &lt;/ul>For more details on how to use this layout, see
<span class='line'>190</span>  * {@link pv.Layout.Cluster}.
<span class='line'>191</span>  *
<span class='line'>192</span>  * @extends pv.Layout.Cluster
<span class='line'>193</span>  */</span><span class="WHIT">
<span class='line'>194</span> </span><span class="NAME">pv.Layout.Cluster.Fill</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Cluster.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Hierarchy.Fill.constructor.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>198</span> 
<span class='line'>199</span> </span><span class="NAME">pv.Layout.Cluster.Fill.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pv.extend</span><span class="PUNC">(</span><span class="NAME">pv.Layout.Cluster</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> 
<span class='line'>201</span> </span><span class="COMM">/** @private */</span><span class="WHIT">
<span class='line'>202</span> </span><span class="NAME">pv.Layout.Cluster.Fill.prototype.buildImplied</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pv.Layout.Cluster.prototype.buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">  </span><span class="NAME">pv.Layout.Hierarchy.Fill.buildImplied.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span></pre></body></html>